Groups in parallel the elements of a sequence according to a key selector function.
The keys are compared by using a comparer and each group's elements are projected by
using a specified function.
Namespace:
System.Linq
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function GroupBy(Of TSource, TKey, TElement) ( _
source As ParallelQuery(Of TSource), _
keySelector As Func(Of TSource, TKey), _
elementSelector As Func(Of TSource, TElement), _
comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of IGrouping(Of TKey, TElement)) |
C# |
---|
public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(
ParallelQuery<TSource> source,
Func<TSource, TKey> keySelector,
Func<TSource, TElement> elementSelector,
IEqualityComparer<TKey> comparer
)
|
Parameters
- source
- Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
An OrderedParallelQuery{TSource}than contains elements to sort.
- keySelector
- Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
- elementSelector
- Type: System..::.Func<(Of <(TSource, TElement>)>)
A function to map each source element to an element in an IGrouping.
- comparer
- Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IComparer{TSource} to compare keys.
Type Parameters
- TSource
- The type of elements of source.
- TKey
- The type of the key returned by keySelector.
- TElement
- The type of the elements in the IGrouping
Return Value
A ParallelQuery{IGrouping{TKey, TElement}} in C# or
ParallelQuery(Of IGrouping(Of TKey, TElement)) in Visual Basic where each IGrouping
generic object contains a collection of objects of type
TElement and a key.
Exceptions
Exception | Condition |
---|
System..::.ArgumentNullException |
source or keySelector or
elementSelector is a null reference (Nothing in Visual Basic).
|
See Also